use psm_lab_prep.dta, clear

*Some recoding*

tsset id period

fvset base 0 c_dummy 
fvset base 0 f_dummy

*** TABLE 3 ***

fracreg logit pc_12 i.c_dummy##i.f_dummy c.psm_s01 i.frame01 i.brain c.age i.female if type == 1, vce(cluster id)
est store m1

fracreg logit pc_12 i.c_dummy##i.f_dummy c.risk_beruf_r i.frame01 i.brain c.age i.female if type == 1, vce(cluster id)
est store m2

fracreg logit pc_12 i.c_dummy##i.f_dummy c.psm_s01 c.risk_beruf_r i.frame01 i.brain c.age i.female if type == 1, vce(cluster id)
est store m3

fracreg logit pc_12 i.c_dummy##i.f_dummy c.psm_s01 i.frame01 i.brain c.age i.female if type == 2, vce(cluster id)
est store m4

fracreg logit pc_12 i.c_dummy##i.f_dummy c.risk_beruf_r i.frame01 i.brain c.age i.female if type == 2, vce(cluster id)
est store m5

fracreg logit pc_12 i.c_dummy##i.f_dummy c.psm_s01 c.risk_beruf_r i.frame01 i.brain c.age i.female if type == 2, vce(cluster id)
est store m6

esttab m1 m2 m3 m4 m5 m6, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) aic bic compress nogaps replace label nobaselevel 
esttab m1 m2 m3 m4 m5 m6 using reg_tab_lab.rtf, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) aic bic compress nogaps replace label nobaselevel 
esttab m1 m2 m3 m4 m5 m6 using reg_tab_lab.csv, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) aic bic compress nogaps replace label nobaselevel 
esttab m1 m2 m3 m4 m5 m6 using reg_tab_lab.tex, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) aic bic compress nogaps replace label nobaselevel 

*** Predictions for plot

est restore m3
margins c_dummy#f_dummy, saving("lab_pred_inspector.dta", replace)

est restore m6
margins c_dummy#f_dummy, saving("lab_pred_inspectee.dta", replace)

est restore m3
margins, at(psm_s01==(.1(.1)1)) level(90) saving("lab_psm_inspector.dta", replace)

est restore m6
margins, at(psm_s01==(.1(.1)1)) level(90) saving("lab_psm_inspectee.dta", replace)

est restore m3
margins, at(risk_beruf_r==(.1(.1)1)) level(90) saving("lab_risk_inspector.dta", replace)

est restore m6
margins, at(risk_beruf_r==(.1(.1)1)) level(90) saving("lab_risk_inspectee.dta", replace)

*** APPENDIX TABLE 3 *** 

reg pc_12 i.c_dummy##i.f_dummy c.psm_s01 i.frame01 i.brain c.age i.female if type == 1, vce(cluster id)
est store m1

reg pc_12 i.c_dummy##i.f_dummy c.risk_beruf_r i.frame01 i.brain c.age i.female if type == 1, vce(cluster id)
est store m2

reg pc_12 i.c_dummy##i.f_dummy c.psm_s01 c.risk_beruf_r i.frame01 i.brain c.age i.female if type == 1, vce(cluster id)
est store m3

reg pc_12 i.c_dummy##i.f_dummy c.psm_s01 i.frame01 i.brain c.age i.female if type == 2, vce(cluster id)
est store m4

reg pc_12 i.c_dummy##i.f_dummy c.risk_beruf_r i.frame01 i.brain c.age i.female if type == 2, vce(cluster id)
est store m5

reg pc_12 i.c_dummy##i.f_dummy c.psm_s01 c.risk_beruf_r i.frame01 i.brain c.age i.female if type == 2, vce(cluster id)
est store m6

esttab m1 m2 m3 m4 m5 m6, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) aic bic compress nogaps replace label nobaselevel 
esttab m1 m2 m3 m4 m5 m6 using reg_tab_lab_ols.csv, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) aic bic compress nogaps replace label nobaselevel 

*** APPENDIX TABLE 4 ***

fracreg logit pc_12 i.c_dummy##i.f_dummy c.psm_f2 i.frame01 i.brain c.age i.female if type == 1, vce(cluster id)
est store m1

fracreg logit pc_12 i.c_dummy##i.f_dummy c.risk_beruf_r i.frame01 i.brain c.age i.female if type == 1, vce(cluster id)
est store m2

fracreg logit pc_12 i.c_dummy##i.f_dummy c.psm_f2 c.risk_beruf_r i.frame01 i.brain c.age i.female if type == 1, vce(cluster id)
est store m3

fracreg logit pc_12 i.c_dummy##i.f_dummy c.psm_f2 i.frame01 i.brain c.age i.female if type == 2, vce(cluster id)
est store m4

fracreg logit pc_12 i.c_dummy##i.f_dummy c.risk_beruf_r i.frame01 i.brain c.age i.female if type == 2, vce(cluster id)
est store m5

fracreg logit pc_12 i.c_dummy##i.f_dummy c.psm_f2 c.risk_beruf_r i.frame01 i.brain c.age i.female if type == 2, vce(cluster id)
est store m6

esttab m1 m2 m3 m4 m5 m6, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) aic bic compress nogaps replace label nobaselevel 
esttab m1 m2 m3 m4 m5 m6 using reg_tab_lab.rtf, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) aic bic compress nogaps replace label nobaselevel 
esttab m1 m2 m3 m4 m5 m6 using reg_tab_lab.csv, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) aic bic compress nogaps replace label nobaselevel 
esttab m1 m2 m3 m4 m5 m6 using reg_tab_lab.tex, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) aic bic compress nogaps replace label nobaselevel 

*** APPENDIX TABLE 6 ***

fracreg logit pc_12 i.c_dummy##i.f_dummy c.app_s i.frame01 i.brain c.age i.female if type == 1, vce(cluster id)
est store m1

fracreg logit pc_12 i.c_dummy##i.f_dummy c.app_s c.risk_beruf_r i.frame01 i.brain c.age i.female if type == 1, vce(cluster id)
est store m2

fracreg logit pc_12 i.c_dummy##i.f_dummy c.app_s i.frame01 i.brain c.age i.female if type == 2, vce(cluster id)
est store m3

fracreg logit pc_12 i.c_dummy##i.f_dummy c.app_s c.risk_beruf_r i.frame01 i.brain c.age i.female if type == 2, vce(cluster id)
est store m4

esttab m1 m2 m3 m4, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) aic bic compress nogaps replace label  nobaselevels 
esttab m1 m2 m3 m4 using reg_tab_lab_sub.rtf, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) aic bic compress nogaps replace label  nobaselevels 
esttab m1 m2 m3 m4 using reg_tab_lab_sub.csv, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) aic bic compress nogaps replace label  nobaselevels 
esttab m1 m2 m3 m4 using reg_tab_lab_sub.tex, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) aic bic compress nogaps replace label  nobaselevels 

